home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MACD 5
/
MACD 5.bin
/
internet
/
irc_i_dodatki
/
remotecli
/
remotecli.amirx
next >
Wrap
Text File
|
1997-02-06
|
25KB
|
882 lines
/*
ABOUT:
This is a test of my ability to make a bot using both AmIRC and
the ARexx scripting language.
Basicly, what we have here is a remotecli and thus the name.
To use it, tell your buddy to /msg <yournick> <cli command>
INSTALLATION:
Put this file into your Amirc/rexx directory otherwise known as
PROGDIR:rexx directory.
then from within amirc type
/rx remotecli install
or if you would like the script to run/accessed from ram: then from
within amirc type
/rx remotecli install ram
it will then setup everything for you.
INSTALLATION IS NOW DONE.
Now reload your default settings using either the menu command under
Settings or reload Amirc. <--- Last option is more reliable.
For a list of switches type /rc help within amirc
for a list of commads type /msg <yournick> help within amirc
to setup a virtual device do /rc set <dirpath> <access level> <virtual device:>
<add/remove>
ie... To setup s: as your scripts: device do the following
/rc set s: 100 scripts: add
To get rid of it do
/rc set s: 100 scripts: remove
For additional help on commands/switches just do /rc <command>
CONTACT INFORMATION:
rlamb@mcia.com
rlamb@lcc.net
dude3k on #amiga_warez
HISTORY:
Prior to first public beta release 9 months of aggressive programming
and learning of arexx for both the language itself and under the
Amirc environment. Also includes aggressive testing of code for flood
stability, and lots of virtual and security functions.
Tuesday Feb. 4, 1997 Fixed quirk on adding virtual devices
- if you left out a colon it'd still
- add the device, however the rest of
- the script wants a colon
- so I added a patch to rectify the
- situation
Wednesday Feb. 5, 1997 Problem in cd command detected and fixed
- invalid usage of rexx functions
- prevented cd'ing into subdirs
Detected problem in virtuallookup()
- Problem fixed.
- Function now verifies against
- security level as well
-- This allows other axxs levels
-- to have the same name for their
-- virtual device names.
Thursday Feb. 6, 1997 Added option to installation procedure
- allows user to have remotecli installed
- to ram:
- Benefits are that you will not see
- access light flicker everytime the
- file get accessed. Also, script loads
- much faster and parses faster thereof.
Added more info to directory function
- now returns file sizes
*/
/* SIGNAL ON SYNTAX */
if ~show('l','rexxsupport.library') then
if ~addlib('rexxsupport.library',0,-30,0) then do
lecho("You don't have rexxsupport.library in your libs:")
exit
end
if ~show('l','rexxsyslib.library') then
if ~addlib('rexxsyslib.library',0,-30,0) then do
lecho("You don't have rexxsyslib.library in your libs:")
exit
end
d = 0
c = 0
options results
x=getclip(server)
if x='' then setclip(server,'0')
x=getclip('localecho')
if x='' then setclip('localecho','on')
GETMYNICK
mynick=RESULT
parse arg rest
parse var rest lcom lrest
check=upper(lcom)
if lcom='CTCP' then do
rest=lrest
end
parse var rest ":"nick"!"username"@"crap"."domain" "method" "rawcommand
parse var rawcommand ":"processed
if lcom='CTCP' then setclip(nick'ctcp','on')
if c2d(substr(processed,1,1))=1 then
processed=strip(processed,'b',substr(processed,1,1))
if username='' then nick="LOCAL" /* no username, it must be local */
/* setup the currentdir for each nick */
test=getclip(nick'cd')
if test='' then do
setclip(nick'cd','root:')
end
select
when check="HELP" then switchhelp()
when check="ECHO" then localecho(lrest)
when check="STAT" then status()
when check="CLEAR" then clear()
when check="SET" then setup(lrest)
when check="INSTALL" then install(lrest)
when check="LIST" then list()
when check="NICK" then nicksecure(lrest)
otherwise nop
end
parse var processed command rest
select
when upper(command)="DIR" then directory(rest)
when upper(command)="CD" then changedir(rest)
when upper(command)="MORE" then more(rest)
when upper(command)="HELP" then help()
when upper(command)="SEND" then sendfile(rest)
when upper(command)="QUIT" then quit()
when upper(command)="XDCC" then help()
otherwise exit
end
/* restore_variables() not needed */
exit
setprocess:
test=getclip(nick'process')
if test='' then do
setclip(nick'process',1)
currentprocess=1
end
else do
test=test+1
currentprocess=test
setclip(nick'process',test)
end
return 0
restore_variables:
if temp.localecho~='' then setclip('localecho',temp.localecho)
return 0
list:
setprocess()
lecho("Current scan settings are: ")
more("s:remotecli","override")
lecho("Scan list complete......")
return 0
setup:
setprocess()
parse arg dest level virtual option .
if option=''|level='' then do
lecho("Usage: /rc set <path> <access level> <virtual device> <add/remove>")
return 0
end
if showdir(dest)='' then do
lecho(dest" is not a valid directory.")
end
else do
if upper(option)="ADD" then do
if exists("s:remotecli") then open('file_io','s:remotecli','a')
else open('file_io','s:remotecli','w')
if right(virtual,1)=':' then
writeln('file_io',dest' 'level' 'virtual)
else
writeln('file_io',dest' 'level' 'virtual':')
close('file_io')
lecho("Directory ["dest"] at level ["level"] added")
lecho("Linked to virtual device: "virtual)
end
else do
if upper(option)="REMOVE" then do
if ~exists("s:remotecli") then lecho("There is nothing to remove!")
else do
open('file_io','s:remotecli','r')
open('file_temp','s:remotecli.tmp','w')
do until eof('file_io')
input=readln('file_io')
parse upper var input olddest oldlevel .
if upper(dest)=oldest & upper(level)=oldlevel then nop
else do
writeln('file_temp',input)
end
end
close('file_temp')
close('file_io')
delete('s:remotecli')
rename('s:remotecli.tmp','s:remotecli')
lecho("Directory ["dest"] at level ["levl"]removed.")
end
end
end
else do
lecho("You must specify an option of either ADD or REMOVE.")
end
end
return 0
status:
setprocess()
bigfatlist=show('c')
x=words(bigfatlist)
lecho("Variables in system are:")
lecho("========================")
lecho("Variable Value")
lecho("========================")
do i=1 to x
variable=word(bigfatlist,i)
value=getclip(variable)
lecho(variable"<-+")
lecho(fillspace(variable)" +->"value)
end
return 0
clear:
bigfatlist=show('c')
x=words(bigfatlist)
"echo P="d2c(27)"b!RemoteCli! Making Memory"
dummy=0
if x~=0 then do
do i=1 to x
currentword=word(bigfatlist,i)
z1=index(currentword,'cd')
z2=index(currentword,'home')
z3=index(currentword,'process')
z=z1 + z2 + z3
if z>0 then do
dummy=dummy+length(currentword)+length(getclip(currentword))
setclip(currentword)
end
end
end
"echo P="d2c(27)"b!RemoteCli! Memory saved from clearing: "dummy"bytes."
return 0
fillspace:
parse arg string
y=length(string)
dummy=''
do j=1 to y
dummy=dummy' '
end
return dummy
help:
setprocess()
clearance=getaxxs(nick)
if clearance=0 then do
display("Sorry, you don't have access to this system.")
display("Please talk to "mynick" about getting access.")
return 0
end
display("====================================")
display("= Commands for remotecli are: =")
display("====================================")
display("= DIR --- show current =")
display("= directory =")
display("= CD / --- go up 1 dir =")
display("= CD <dest> --- change directory =")
display("= MORE <file> --- read a file =")
display("= QUIT --- stops remotecli =")
display("= same as BREAK =")
display("= SEND <file> --- this is how you =")
display("= get what you =")
display("= want =")
display("= HELP --- get this help =")
display("====================================")
display("= NOTE NOTE NOTE NOTE NOTE NOTE =")
display("====================================")
display("= if you want to send anything =")
display("= just do a normal dcc send to =")
display("= "mynick)
display("====================================")
return 0
makespace:
parse arg x string
do i=1 to x-1
string=string' '
end
return string'='
quit:
setprocess()
display("Previous process aborted!") /* it is setprocess */
checkprocess() /* and checkprocess that do the quitting */
return 0
checkprocess:
test=getclip(nick'process')
if test~=currentprocess then do
exit
end
return 0
more:
currentdir=getclip(nick'cd')
clearance=getaxxs(nick)
if clearance=0 then do
setprocess()
display("Sorry, you don't have access to this system.")
display("Please talk to "mynick" about getting access.")
return 0
end
parse arg newtarget level .
if level~="override" then do
setprocess()
parse var currentdir virtual':'rest
success=1
actualdir=virtuallookup(virtual':')
if actualdir='bogus' then success=0
realdir=actualdir||rest
if right(realdir,1)=':' | right(realdir,1)='/' then realfile=realdir||strip(newtarget)
else realfile=realdir||'/'||strip(newtarget)
if exists(realfile) then do
open('more_io',realfile,'r')
success=1
end
else success=0
end
else open('more_io',newtarget,'r')
if success=1 then do
display("More of file "newtarget" started")
do until eof('more_io')
display(readln('more_io'))
end
display("More of file "target" finished")
close('more_io')
end
else display("The file does not exist!")
return 0
getaxxs: /* get users security level */
parse arg user .
returncode=0
USERHOST user
umask=RESULT
if open('f','s:remotecli.axxs','r') then do
do until eof('f')
input=readln('f')
parse var input item.axxs level mask .
parse var mask u1'@'crap1'.'mask1 .
parse var umask u2'@'crap2'.'mask2 .
if upper(item.axxs)=upper(user) & mask1=mask2 then do
close('f')
return level
end
end
close('f')
end
else do
display("axxs file not set!")
end
close('f')
return returncode
nicksecure:
setprocess()
parse arg whichnick option level .
USERHOST whichnick
mask=RESULT
if upper(option)='ADD' then do
if exists('s:remotecli.axxs') then open('file_io','s:remotecli.axxs','a')
else open('file_io','s:remotecli.axxs','w')
writeln('file_io',whichnick' 'level' 'mask)
close('file_io')
display(whichnick" from host "mask" added at level "level)
end
else if upper(option)="REMOVE" then do
if exists('s:remotecli.axxs') then do
open('file_io','s:remotecli.axxs','r')
open('file_temp','s:remotecli.axxs.tmp','w')
do until eof('file_io')
input=readln('file_io')
parse arg testnick level umask .
if upper(testnick)=upper(whichnick) then do
display(whichnick" from host "mask" removed.")
end
else writeln('file_temp',input)
end
close('file_io')
close('file_temp')
delete('s:remotecli.axxs')
rename('s:remotecli.axxs.tmp','s:remotecli.axxs')
display("Process finished.")
end
else display("You must add people first!")
end
else do
display("USAGE: /rc nick <usernick> <add/remove> <securitylevel>")
end
close('file_io')
close('file_temp')
return 0
matchdomain:
parse arg domain1 domain2
parse upper var domain1 u1'@'crap'.'domain1 .
parse upper var domain2 u2'@'crap'.'domain2 .
if u1=u2 & domain1=domain2 then return 1
return 0
checkclearance:
/* return 1, for has axxs to dir, 0 for no access */
/* cross reference userlevel against item's various seclevels that */
/* are recording in an xxs file */
parse arg user','userlevel','item .
returncode=0
if open('file_io','s:remotecli','r') then do
do until eof('file_io')
input=readln('file_io')
parse var input axxs.item axxs.level axxs.virtualdevice .
if axxs.level=userlevel & axxs.virtualdevice=item then do
returncode=1
end
end
close('file_io')
end
return returncode
virtuallookup:
string='bogus'
parse arg test.virtual .
clearance=getaxxs(nick)
if ~open('file_io','s:remotecli','r') then do
string='root'
end
else do
do until eof('file_io')
input=readln('file_io')
parse var input axxs.item axxs.level axxs.virtual .
if upper(axxs.virtual)=upper(test.virtual) & clearance=axxs.level then do
string=axxs.item
leave
end
end
end
close('file_io')
return string
directory:
setprocess()
clearance=getaxxs(nick) /* clearance is level of user */
if clearance=0 then do
display("Sorry, you don't have access to this system.")
display("Please talk to "mynick" about getting access.")
return 0
end
currentdir=getclip(nick'cd')
parse arg target switches
brag()
if currentdir='root:' then do
display("Root: list started...")
if open('f','s:remotecli','r') then do /* look at files & axxs */
do until eof('f')
input=readln('f')
parse var input item level virtualdevice .
if checkclearance(nick','clearance','virtualdevice) then display(virtualdevice)
end
close('f')
end
display("Root: list finished...")
end
else do
if substr(currentdir,length(currentdir),1)=":" then do
if ~checkclearance(nick','clearance','currentdir) then do
display("You don't have access to "currentdir)
return 0
end
end
parse var currentdir virtual':'rest .
actualdir=virtuallookup(virtual':')
currentdir=actualdir||rest
dirslist=showdir(currentdir,'d')
filelist=showdir(currentdir,'f')
do choose=1 to 2
select
when choose=1 then list=dirslist
when choose=2 then list=filelist
end
x=words(list)
do i=1 to x
item=word(list,i)
if choose=1 then do
item=item'/'
display(item)
end
if choose=2 then do
if right(currentdir,1)=':' | right(currentdir,1)='/' then
info=statef(currentdir||item)
else
info=statef(currentdir||'/'||item)
parse var info crap bytes crap .
formatstring=" "
formatstring=overlay(item,formatstring,1,length(item),' ')
formatstring=overlay(bytes,formatstring,25,length(bytes),' ')
formatstring=overlay('bytes',formatstring,33,5,' ')
display(formatstring)
end
end
end
end
display("Directory List Finished!")
return 0
sendfile:
setprocess()
currentdir=getclip(nick'cd')
clearance=getaxxs(nick)
if clearance=0 then do
display("Sorry, you don't have access to this system.")
display("Please talk to "mynick" about getting access.")
return 0
end
parse arg target
target=strip(target)
brag()
filename=currentdir||target
parse var filename virtual':'filename
actualdir=virtuallookup(virtual':')
if right(actualdir,1)=':' | right(actualdir,1)='/' then realfileame=actualdir||filename
else realfilename=actualdir||'/'||filename
if exists(realfilename) then do
display("File: "target" is now being sent to you")
display("Please initiate your dcc receive")
"say /DCC SEND "nick realfilename
end
else do
display("File: "target" does not exist")
display("Please check your spelling & location")
end
return 0
changedir:
setprocess()
clearance=getaxxs(nick)
if clearance=0 then do
display("Sorry, you don't have access to this system.")
display("Please talk to "mynick" about getting access.")
return 0
end
currentdir=getclip(nick'cd') /* get current directory */
parse var currentdir virtual':'currentdir . /* pull out virtual device */
saverest=currentdir /* reuse of currentdir is too high */
/* so we save it's contents */
virtual=virtual':'
parse arg target /* what are cd'ing to */
target=strip(target) /* get rid of those blanks */
test.cd=0 /* initialize slash counter */
do i=1 to length(target)
if substr(target,i,1)='/' then /* count slashes in target */
test.cd=test.cd+1
end /* test.cd = how many times we */
/* must cd up */
root.dir='' /* initialize check for root cd */
if substr(target,length(target),1)=':' then
root.dir='yes' /* we have a request to change */
brag()
temp.l=length(currentdir) /* find out length of current dir */
if root.dir='yes' then do /* handle requests for virtual devices */
if upper(target)~='ROOT:' then do
clearance=getaxxs(nick)
if checkclearance(nick','clearance','target) then do
currentdir='target'
setclip(nick'cd',target)
display("Directory set to "target)
return 0
end
else do
display("You don't have access to "target)
return 0
end
end
else do
currentdir=''
setclip(nick'cd','root:')
display("Directory set to "target)
return 0
end
end
if test.cd~=0 then do /* handle requests for cd ups */
test.temp=0
shittemp=currentdir
do forever
parse var shittemp test.test'/'rest .
if rest='' & test.test='' then leave
test.temp=test.temp+1
shittemp=rest
end
if test.temp=0 & test.test='' then do
currentdir=''
setclip(nick'cd','root:')
display("Directory set to root:")
return 0
end
if test.temp=0 & test.cd=1 then do
currentdir=''
setclip(nick'cd',virtual)
display("Directory set to "virtual)
return 0
end
if test.temp=0 & test.cd>1 then do
currentdir=''
setclip(nick'cd','root:')
display("Directory set to root:")
return 0
end
if test.temp>0 & test.cd>0 then do
if test.cd>test.temp+1 then do
currentdir=''
setclip(nick'cd','root:')
display("Directory set to root:")
return 0
end
if test.cd=test.temp then do
currentdir=''
setclip(nick'cd',virtual)
display("Directory set to "virtual)
return 0
end
if test.cd<test.temp then do
test.currentdir=reverse(currentdir)
test.newdir=''
do i=1 to test.cd
parse var test.currentdir crap'/'test.currentdir
end
currentdir=virtual||reverse(test.currentdir)
setclip(nick'cd',currentdir)
display("Directory set to "currentdir)
return 0
end
end
end
/* handle remainder of target */
actualdir=virtuallookup(virtual)
currentdir=saverest
if right(currentdir,1)='/' | right(currentdir,1)=':' then
testdir=actualdir||currentdir||target
else
if currentdir='' then testdir=actualdir||target
else testdir=actualdir||currentdir||'/'||target
if showdir(testdir)='' & ~exists(testdir) then do
currentdir=virtual||currentdir
setclip(nick'cd',currentdir)
display("Directory not valid!")
display("Directory remains at "currentdir)
end
else do
if right(currentdir,1)='/' | right(currentdir,1)=':' then
currentdir=virtual||currentdir||target
else
if currentdir='' then currentdir=virtual||target
else currentdir=virtual||currentdir||'/'||target
setclip(nick'cd',currentdir)
display("Directory set to "currentdir)
end
return 0
display:
parse arg string
checksend()
if upper(nick)~=upper(mynick) & upper(nick)~="LOCAL" then do
"RAW PRIVMSG "nick" :"d2c(2)"!RemoteCli!"d2c(2) string
if getclip(nick'ctcp')~='on' then
delay(30)
end
setclip(sending)
lecho(string)
return 0
lecho:
parse arg string
checksend()
lnick=nick
if upper(nick)=upper(mynick) then lnick='LOCAL'
if getclip('localecho')='on' | upper(nick)=upper(mynick) then
"echo P="d2c(27)"b!RemoteCli! ["lnick"]"string
delay(30)
setclip(sending)
return 0
checksend:
checkprocess()
b=0
c=getclip(server)
c=c+1
do forever
b=b+1
sendit=getclip(sending)
if sendit='' then do
setclip(sending,nick)
leave
end
if b=25 then do
setclip(sending,'')
end
end
if getclip(nick'ctcp')~='on' then do
if c>9 then do
c=0
delay(100)
end
setclip(server,c)
end
return 0
switchhelp:
setprocess()
lecho("------------------------------------------------")
lecho("- Welcome to REMOTE CLI by DUDE3K -")
lecho("------------------------------------------------")
lecho("- Switches are: -")
lecho("- -")
lecho("- HELP --- Coughs up this -")
lecho("- help -")
lecho("- ECHO ON --- local echo on -")
lecho("- OFF or off -")
lecho("- SET <dir> --- set a default -")
lecho("- directory for -")
lecho("- scanning. -")
lecho("- NICK <username> <add/remove> <securitylevel> -")
lecho("- --- self explanatory -")
lecho("- CLEAR --- clears out all -")
lecho("- vars created by -")
lecho("- RemoteCli -")
lecho("- STAT --- Show all vars -")
lecho("- INSTALL --- Install RemoteCli -")
lecho("- End of help -")
lecho("------------------------------------------------")
return 0
localecho:
setprocess()
parse upper arg test .
select
when test='OFF' then do
setclip('localecho','on')
lecho("Local Echo is now OFF!")
setclip('localecho','off')
end
when test='ON' then do
setclip('localecho','on')
lecho("Local Echo is now ON!")
end
otherwise nop
end
return 0
brag:
lecho("User "nick" has entered the system!")
display("Welcome to "mynick"'s CLI via REMOTECLI by DUDE3K")
return 0
install:
parse upper arg option .
setprocess()
if ~exists('rexx/remotecli.amirx') then do
lecho("You do not have remotecli.amirx")
lecho("Please put remotecli.amirx")
lecho("in the amirc/rexx directory")
lecho("Then try the install again.")
return 0
end
if ~exists('default.amircfg') then do
lecho("For some reason you don't have")
lecho("default settings file.")
lecho("Please, use save as defaults to")
lecho("create one.")
lecho("The try the install again.")
return 0
end
open('da','default.amircfg','r')
open('t','temp','w')
setclip(alias,'notdone')
do until eof('da')
input=readln('da')
parse var input sect1' '.
select
when upper(sect1)='ALIAS' & getclip(alias)='notdone' then makealias(option'::'input)
when upper(sect1)='EVENT_CTCP' then makectcp(option'::'input)
when upper(sect1)='EVENT_PRIV' then makepriv(option'::'input)
otherwise makedoody(input)
end
end
close('da')
close('t')
open('us','s:user-startup','a')
writeln('us',';BEGIN REMOTECLI IN RAM')
writeln('us','copy rexx:remotecli.amirx ram:')
writeln('us',';END REMOTECLI IN RAM')
address command 'copy rexx/remotecli.amirx rexx:'
close('us')
delete('default.amircfg')
rename('temp','default.amircfg')
lecho("Please do /rc help for local help")
lecho("Tell your fiends to use /msg "mynick" help for remote help")
lecho("Also inform them to use the commands in the format of")
lecho("/msg "mynick" <command> <options>")
lecho("INSTALLATION ALL DONE.")
lecho("Please reload your configuration from default to activate.")
return 0
makealias:
parse arg option'::'crap
writeln('t',crap)
if option='RAM' then writeln('t','ALIAS rc /rx ram:remotecli %p')
else writeln('t','ALIAS rc /rx rexx/remotecli %p')
setclip(alias,'done')
lecho("Alias /rc added to system")
return 0
makectcp:
parse arg option'::'rest
rest=strip(rest)
rest=reverse(rest)
x=pos(',',rest)
firstpart=substr(rest,x)
firstpart=reverse(firstpart)
if option='RAM' then firstpart=firstpart'ram:remotecli.amirx CTCP %p'
else firstpart=firstpart'rexx/remotecli.amirx CTCP %p'
writeln('t',firstpart)
lecho("CTCP EVENT SET")
return 0
makepriv:
parse arg option'::'rest
rest=strip(rest)
rest=reverse(rest)
x=pos(',',rest)
firstpart=substr(rest,x)
firstpart=reverse(firstpart)
if option='RAM' then firstpart=firstpart'ram:remotecli.amirx %p'
else firstpart=firstpart'rexx/remotecli.amirx %p'
writeln('t',firstpart)
lecho("PRIVMSG EVENT SET")
return 0
makedoody:
parse arg crap
writeln('t',crap)
return 0
FAILURE:
ERROR:
IOERR:
SYNTAX:
"echo P="d2c(27)"b!ERROR! ON LINE #"sigl
"echo P="d2c(27)"b!ERROR! CODE #"rc
"echo P="d2c(27)"b!ERROR! DESCRIPTION:"errortext(rc)
exit